<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<body style="margin: 0 20px">

<fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
    <form class="layui-form serch" action="{:url('admin/faq/index')}" method="post">
        <div class="layui-form-item" style="float: left;">
            <div class="layui-input-inline">
                <input type="text" name="keywords" autocomplete="off" value="{if isset($wherelist['keywords'])}{$wherelist['keywords']}{/if}" lay-verify="title" placeholder="请输入查询名称" class="layui-input layui-btn-sm">
            </div>
            <div class="layui-input-inline">
                <div class="layui-inline">
                    <select name="typeid" lay-search="" lay-filter="typeidSelect" id="typeidSelect">
                        <option value="1" {if isset($wherelist['typeid']) AND $wherelist['typeid']==1 }selected{/if}>产品</option>
                        <!--<option value="2" {if isset($wherelist['typeid']) AND $wherelist['typeid']==2 }selected{/if}>POI</option>-->
                        <option value="3" {if isset($wherelist['typeid']) AND $wherelist['typeid']==3 }selected{/if}>Viator商品</option>
                        <option value="9" {if isset($wherelist['typeid']) AND $wherelist['typeid']==9 }selected{/if}>产品开发需求</option>
                        <option value="4" {if isset($wherelist['typeid']) AND $wherelist['typeid']==4 }selected{/if}>供应商</option>
                        <option value="5" {if isset($wherelist['typeid']) AND $wherelist['typeid']==5 }selected{/if}>目的地</option>
                        <option value="6" {if isset($wherelist['typeid']) AND $wherelist['typeid']==6 }selected{/if}>销售话术</option>
                        <option value="7" {if isset($wherelist['typeid']) AND $wherelist['typeid']==7 }selected{/if}>新人培训</option>
                        <option value="8" {if isset($wherelist['typeid']) AND $wherelist['typeid']==8 }selected{/if}>定制行程方案</option>
                    </select>
                </div>
            </div>

            <button class="layui-btn layui-btn-danger layui-btn-sm" lay-submit="" lay-filter="serch" id="typeSearch">立即查询</button>
            {if $typeid==6 || $typeid==7 || $typeid==8 || $typeid==9}
            <button class="layui-btn layui-btn-normal layui-btn-sm" id="addTitle">添加条目</button>
            {/if}
        </div>
    </form>

</fieldset>

<table class="layui-table" lay-even="" lay-skin="row" lay-size="sm">
    <colgroup>
        {if $typeid==8}
        <col width="15%">
        <col width="45%">
        <col width="15%">
        <col width="15%">
        <col width="10%">
        {else}
        <col width="15%">
        <col width="45%">
        <col width="15%">
        <col width="15%">
        {/if}
    </colgroup>
    <thead>
    <tr>
        <th>ID</th>
        <th>名称</th>
        <th>FAQ条数</th>

        {if $typeid==8 || $typeid==9}
        <th>创建人</th>
        {/if}

        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {if !empty($info)}
    {volist name="info" id="vo"}
    <tr>
        <td>{$vo.id}</td>
        {if $typeid==4}
        <td>
            <a href="{$vo.url}" target="_blank" style="text-decoration:underline;color:blue;">{$vo.name}</a>
        </td>
        {else}
        <td>{$vo.name}</td>
        {/if}
        <td>{$vo.counts}</td>
        {if $typeid==8 || $typeid==9}
        <td>{$vo.creater}</td>
        {/if}
        <td>
            <a href="{:url('admin/faq/showFaq',['groupid'=>$vo.id,'typeid'=>$typeid])}" class="layui-btn layui-btn-xs layui-btn-warm" target="_blank"  style="margin-right: 0;font-size:12px;">FAQ</a>
        </td>
    </tr>
    {/volist}
    {/if}
    </tbody>
</table>
{if !empty($info) && $typeid<4}
<div style="padding:0 20px;">{$info->render()}</div>
{/if}
<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>

<script>
    layui.use(['layer','form'], function(){
        var layer = layui.layer;
        var form = layui.form;
        $('.a_menu').click(function(){
            var url = $(this).attr('href');
            var a = 0;
            $.ajax({
                url:url
                ,async:false
                ,success:function(res){
                    if(res.code == 0) {
                        layer.msg(res.msg);
                        a = 1;
                    }
                }
            });
            if(a === 0) {
                layer.open({
                    type:2,
                    content:[url, 'no'],
                    area: ['700px', '500px'],
                    end:function(){
                        location.reload();
                    }
                });
            }
            return false;
        });


        $("#addTitle").click(function(){
            var typeid = $("#typeidSelect").val();
            layer.prompt({title: "设置新增条目标题"},function(val, index){
                var flag = 0;
                $.ajax({
                    url:"{:url('admin/faq/addTitle')}",
                    data:{typeid:typeid,title:val},
                    type:'post',
                    async: false,
                    success:function(res) {
                        flag = res.code;
                        layer.msg(res.msg);
                    }
                });

                layer.close(index);
                if(flag == 1) {
                    setTimeout(function(){
                        location.reload();
                    },1500)
                }
            });
            return false;
        });


        form.on('select(typeidSelect)', function(data){
            $('#typeSearch').trigger("click");
        });


    });
</script>
</body>
</html>
